package ex;

public class TryCatchFinally {
	
	public static void parseJava(String s) throws MyException{
		if(s.toLowerCase().equals("java")){
			System.out.println("Java is successfully parsed.");
		}else{
			throw new MyException("You are not JAVA guy.");
		}
	}

	public static void testNumeric(String s) {

		try {
			Integer.parseInt(s);
		} catch (NumberFormatException e) {
			System.out.println(String.format(
					"\"%s\" is not a valid number format.", s));
		} finally {
			System.out.println("The program is over.");
		}
	}

	public static void main(String[] args) {
		TryCatchFinally.testNumeric("two");
		System.out.println("======================");
		TryCatchFinally.testNumeric("12");
		System.out.println("======================");
		TryCatchFinally.testNumeric("12.00");
		System.out.println("======================");
		try {
			TryCatchFinally.parseJava("CSharp");
		} catch (MyException e) {
			System.out.println(e.getMessage());
		}
		
		try {
			TryCatchFinally.parseJava("JAVA");
		} catch (MyException e) {
			System.out.println(e.getMessage());
		}
	}

}
